package net.csdn.business.common.feign.oauth2;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.common.constant.ServiceNameConstants;
import net.csdn.business.common.domain.request.oauth.PersonalAccessTokenDTO;
import net.csdn.business.common.domain.request.oauth.PersonalAccessTokenQuery;
import net.csdn.business.common.domain.request.oauth.RevokedPersonTokenDTO;
import net.csdn.business.common.domain.vo.oauth.OauthTokenInfoVO;
import net.csdn.business.common.domain.vo.oauth.PersonalAccessTokenVO;
import net.csdn.business.common.feign.oauth2.config.AuthFeignConfiguration;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;


/**
 * @Desc: auth服务提供私人token相关接口
 * @Author: zhangyalei
 * @Date: 2022/12/19 13:51
 */
@FeignClient(value = ServiceNameConstants.ATOMGIT_AUTH_SERVICE,contextId = ServiceNameConstants.ATOMGIT_AUTH_PERSON_CONTEXT_ID, configuration = AuthFeignConfiguration.class)
public interface AuthPersonTokenFeignClient {


	/**
	 * 分页查询私人token
	 * @param params
	 * @return
	 */
	@PostMapping("/api/v1/personalToken/list")
	public Page<PersonalAccessTokenVO> findPageList(@RequestBody PersonalAccessTokenQuery params);


	/**
	 * @Desc: 新增私人token
	 * @Author: zhangyalei
	 * @Date: 2022/12/19 17:44
	 */
	@PostMapping("/api/v1/personalToken/add")
	public PersonalAccessTokenVO addPersonalAccess(@RequestBody PersonalAccessTokenDTO params);


	/**
	 * @Desc: 根据id撤销私人token
	 * @Author: zhangyalei
	 * @Date: 2022/12/19 17:44
	 */
	@PostMapping("/api/v1/personalToken/revoked")
	public Integer revokedPersonToken(@RequestBody RevokedPersonTokenDTO params);


	/**
	 * @Desc: 根据userId撤销本人所有私人token
	 * @Author: zhangyalei
	 * @Date: 2022/12/19 17:44
	 */
	@PostMapping("/api/v1/personalToken/revokedAll")
	public Integer revokedAllPersonToken(@RequestBody RevokedPersonTokenDTO params);

	/**
	 * @Desc: 根据token获取token包含的用户信息、以及scope
	 * @Author: zhangyalei
	 * @Date: 2023/03/16 17:00
	 */
	@GetMapping("/api/v1/personalToken/getInfo")
	public OauthTokenInfoVO getInfo(@RequestParam("token")String token);

}
